package com.qidian.mes.defect.controller;

import com.qidian.mes.defect.service.DefectService;
import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.Defect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 泽华
 * @Description
 * @Time 2024-10-16 16:42
 */
@RestController
@CrossOrigin
@RequestMapping("/defect")
public class DefectController {
    @Autowired
    private DefectService defectService;
    @PostMapping("/save")
    public MESResult save(@RequestBody Defect defect){
        return defectService.save(defect);
    }
    @DeleteMapping("/delete")
    public MESResult delete(Long defectId){
        return defectService.delete(defectId);
    }

    @DeleteMapping("/deletes")
    public MESResult deletes(Long[] defectIds){
        return defectService.deletes(defectIds);
    }
    @PutMapping("/update")
    public MESResult update(@RequestBody Defect defect){
        return defectService.update(defect);
    }
    @GetMapping("/list")
    public MESResult list(String defectDescription,String defectType,String defectGrade,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10") int limit){
        return defectService.list(defectDescription,defectType,defectGrade,page,limit);
    }

    //通过id查询这条数据
    @GetMapping("/get")
    public MESResult get(Long defectId){
        return defectService.selectById(defectId);
    }



}
